package com.foreknow.demo07;

import java.util.Scanner;

/**
 * 1.掌握方法的基本语法
 * 2.方法的参数都可以传递哪些类型
 */
public class TestMesthod {

  public void a(int a){
    System.out.println(a);
  }

  public void b(String s) {
    System.out.println(s);
  }

  public void c(double d) {
    System.out.println(d);
  }

  public void d(int[] array) {
    for(int i = 0;i<array.length;i++){
      System.out.println(array[i]);
    }
  }

  public void e(Person person) {
    person.eat();
  }

  public void f(Scanner input) {
    System.out.println("请输入用户名");
    String name = input.next();
    System.out.println(name);
  }

  public static void main(String[] args) {
    TestMesthod testMesthod = new TestMesthod();
    testMesthod.a(1);
    testMesthod.b("tom");
    testMesthod.c(3.14);
    System.out.println("-----------------------------------");
    int[] array = {1,2,3,4,5,6,7};
    testMesthod.d(array);

    Person person = new Person("tom",30);
    testMesthod.e(person);

    System.out.println("-----------------------------------");

    Scanner sc = new Scanner(System.in);
    testMesthod.f(sc);
  }

}
